#include "find.h"

int find_first_basic(int value, int nums[], int size)
{
    // time O(n)
    for(int i = 0; i < size; ++ i)
    {
        if(nums[i] == value)
        {
            return i;
        }
    }
    return -1;
}

int find(int value, int nums[], int start, int end)
{
    if(start > end)
    {
        return -1;
    }
    int mid_index = (end + start)/2;
    int mid_value = nums[mid_index];
    if(value == mid_value)
    {
        return mid_index;
    }
    else if(start == end)
    {
        return -1;
    }
    if(value > mid_value)
    {
        return find(value, nums, mid_index + 1, end);
    }
    else
    {
        return find(value, nums, start, mid_index - 1);        
    }
}